package com.cc.controller;

import com.cc.comm.responce.PageResult;
import com.cc.comm.responce.R;
import com.cc.model.dto.EmployeeQuery;
import com.cc.model.entity.Employees;
import com.cc.service.EmployeesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 员工登录表 前端控制器
 * </p>
 *
 * @author 晓东√
 * @since 2025-09-19 11:18
 */
@RestController
@RequestMapping("/employees")
@Tag(name = "员工控制器接口", description = "员工控制器接口")
public class EmployeesController {
    @Autowired
    private EmployeesService employeesService;

    //实现登录功能
    @PostMapping("/login")
    @Parameters({
            @Parameter(name = "username", description = "用户名"),
            @Parameter(name = "password", description = "密码")
    })
    public Employees login(String username, String password) {
        //TODO: 登录功能实现
        return null;
    }
    @PostMapping("/getEmployee/{id}")
    @Operation(summary = "通过员工Id获取员工信息")
    @Parameter(name = "id", description = "员工ID")
    public R<Employees> getEmployeeById(@PathVariable Integer id) {
        // 通过员工Id获取员工信息功能实现
        return R.success(employeesService.getById(id));
    }

    //分页获取员工列表
    @PostMapping("/pageList")
    @Operation(summary = "分页获取员工列表")
    @Parameters({
            @Parameter(name = "pageNum", description = "当前页码"),
            @Parameter(name = "pageSize", description = "每页数量"),
            @Parameter(name = "username", description = "员工名称"),
            @Parameter(name = "phone", description = "员工手机")
    })
    public R<PageResult<Employees>> getEmployeeList(EmployeeQuery  employeeQuery) {
        //分页获取员工列表功能实现
        return R.success(employeesService.getEmployeeList(employeeQuery));
    }

    @PostMapping("/edit")
    @Operation(summary = "编辑员工信息")
    public R editEmployee(@RequestBody Employees employee) {
        //编辑员工信息功能实现
        employeesService.editEmployee(employee);
        return R.success();
    }

    //重置密码功能
    @GetMapping("/resetPassword/{id}")
    @Operation(summary = "重置密码")
    @Parameter(name = "id", description = "员工ID")
    public R resetPassword(@PathVariable Integer id) {
        //重置密码功能实现
        employeesService.resetPassword(id);
        return R.success();
    }



}
